using Microsoft.AspNetCore.Mvc;
using zhwy.saas.api.Entity.Sys;
using zhwy.saas.api.Models;
using zhwy.saas.api.Services.Sinterface.Sys;

namespace zhwy.saas.api.Controllers.V1.Sys
{
    /// <summary>
    /// 系统权限管理
    /// </summary>
    [ApiVersion("1.0")]
    public class SysPermissionController : BaseController<PermissionsEntity>
    {
        private readonly ISysPermissionService _sysPermissionService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="sysPermissionService">权限服务</param>
        public SysPermissionController(ISysPermissionService sysPermissionService)
            : base(sysPermissionService)
        {
            _sysPermissionService = sysPermissionService;
        }

        ///// <summary>
        ///// 获取角色权限
        ///// </summary>
        ///// <param name="roleId">角色ID</param>
        ///// <returns>权限列表</returns>
        ///// <response code="200">成功获取权限列表</response>
        //[HttpGet("role/{roleId}")]
        //[ProducesResponseType(typeof(ApiResponse<List<PermissionsEntity>>), 200)]
        //public async Task<ActionResult<ApiResponse<List<PermissionsEntity>>>> GetRolePermissions(long roleId)
        //{
        //    var permissions = await _sysPermissionService.GetPermissionsByRoleIdAsync(roleId);
        //    return ApiResponse<List<PermissionsEntity>>.Ok(permissions);
        //}

        ///// <summary>
        ///// 获取用户权限
        ///// </summary>
        ///// <param name="userId">用户ID</param>
        ///// <returns>权限列表</returns>
        ///// <response code="200">成功获取权限列表</response>
        //[HttpGet("user/{userId}")]
        //[ProducesResponseType(typeof(ApiResponse<List<PermissionsEntity>>), 200)]
        //public async Task<ActionResult<ApiResponse<List<PermissionsEntity>>>> GetUserPermissions(long userId)
        //{
        //    var permissions = await _sysPermissionService.GetPermissionsByUserIdAsync(userId);
        //    return ApiResponse<List<PermissionsEntity>>.Ok(permissions);
        //}

        ///// <summary>
        ///// 获取菜单权限
        ///// </summary>
        ///// <returns>权限列表</returns>
        ///// <response code="200">成功获取权限列表</response>
        //[HttpGet("menu/list/permcodes")]
        //[ProducesResponseType(typeof(ApiResponse<List<PermissionsEntity>>), 200)]
        //public async Task<ActionResult<ApiResponse<List<PermissionsEntity>>>> GetMenuPermissions(List<string> permcodes)
        //{
        //    var permissions = await _sysPermissionService.GetPermissionsByPermcodesAsync(permcodes);
        //    return ApiResponse<List<PermissionsEntity>>.Ok(permissions);
        //}

        ///// <summary>
        ///// 批量保存权限
        ///// </summary>
        ///// <param name="permissions">权限列表</param>
        ///// <returns>保存结果</returns>
        ///// <response code="200">权限保存成功</response>
        ///// <response code="400">权限保存失败</response>
        //[HttpPost("batch")]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 200)]
        //[ProducesResponseType(typeof(ApiResponse<bool>), 400)]
        //public async Task<ActionResult<ApiResponse<bool>>> SavePermissions([FromBody] List<PermissionsEntity> permissions)
        //{
        //    var result = await _sysPermissionService.SavePermissionsAsync(permissions);
        //    return result
        //        ? ApiResponse<bool>.Ok(true, "权限保存成功")
        //        : ApiResponse<bool>.Error("权限保存失败");
        //}
    }
}